﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Text
{
    public partial class html2Article : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = "B";
            switch (type)
            {
                case "A": A(); break;
                case "B": B(); break;
                default: break;
            }
        }
        //GetArticle
        private void A()
        {
            string url = "http://www.cnblogs.com/ryuasuka/p/3594777.html";
            string html = MSL.Utility.Html.HtmlHelper.Instance.GetHtml(url);

            Stopwatch sw = new Stopwatch();
            sw.Start();
            MSL.Utility.Html.Article article = MSL.Utility.Html.Html2Article.GetArticle(html);
            sw.Stop();
            string mes = "提取耗时：" + Environment.NewLine + sw.ElapsedMilliseconds + "毫秒";

            string pubtime = article.PublishDate.ToString();
            string title = article.Title;
            string content1 = article.Content;
            string content2 = article.ContentWithTags;
        }
        //TextExtract
        private void B()
        {
            string url = "http://www.cnblogs.com/ryuasuka/p/3594777.html";
            string html = MSL.Utility.Html.HtmlHelper.Instance.GetHtml(url);

            Stopwatch sw = new Stopwatch();
            sw.Start();
            MSL.Tool.HtmlExtract article = new MSL.Tool.HtmlExtract(html, true);
            sw.Stop();
            string mes = "提取耗时：" + Environment.NewLine + sw.ElapsedMilliseconds + "毫秒";

            string title = article.Title;
            string content1 = article.Content;
            string content2 = article.WebPreview;
        }

    }
}